package com.lhf.person.controller;

import com.lhf.person.entity.Person;
import com.lhf.person.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class PersonController {
    @Autowired
    private PersonService service;
    @RequestMapping("/index")
    public String toIndex(){
        System.out.println("index被执行了");
        return "index";
    }
    @RequestMapping("/found")
    @ResponseBody
    public Object foundperson(@RequestParam(required = false,defaultValue = "") String name,
                              @RequestParam(required = false,defaultValue = "-1")int sex,
                              @RequestParam(required = false,defaultValue = "1")int pageindex){
        Page<Person> people = service.foundPerson(name, sex, pageindex);
        System.out.println(people);
        return people;
    }
    @RequestMapping("/getxxx")
    @ResponseBody
    public  Object getxxx(int id){
        return service.getintroduce(id);
    }

}
